/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package yuhuibear.poat.test.entity;

import yuhuibear.poat.annotations.action.AutoGenerateValue;
import yuhuibear.poat.annotations.action.Macro;
import yuhuibear.poat.annotations.relation.Field;
import yuhuibear.poat.annotations.relation.Table;
import yuhuibear.poat.object.bean.Bean;

/**
 * 数据库实体对象的映射。
 * 
 * @author yuhui_bear
 */

@SuppressWarnings("serial")
@Table(name = "users", constrain = "")
public class User implements Bean {

	@Macro(name = "r1", depend = "")
	public String creatR1() {
		return "create table r1(id int)";
	}

	@AutoGenerateValue(skipOnNull = true, sqlToGet = "select currval('users_id_seq')")
	@Field(name = "id", type = "bigserial", constrain = " primary key")
	private Long id;

	@Field(name = "data ", type = "int8[]", constrain = "")
	private Long[] datas;

	@Field(name = "commentby", type = "numeric(10,2)", constrain = "")
	String cmt;

	@Field(name = "name", type = "varchar(40)", constrain = "")
	protected String name;

	@Field(name = "credite", type = "numeric(10,2)", constrain = "")
	Double credite;

	// ////////////////////////////////////////////////////////
	@Macro(name = "a1", depend = "a2")
	public String creatA1() {
		return "create table a1(id int, fid int references a2(id))";
	}

	@Macro(name = "a2", depend = "")
	public String createA2() {
		return "create table a2(id int primary key)";
	}

	@Macro(name = "c1", depend = "d1")
	public String createC1() {
		return "create table c1(id int, fid int references d1(id))";
	}

	public User() {}

	@Override
	public String toString() {
		return "id : " + id + ", name : " + name + ", credite : " + credite
				+ ", commentby : " + cmt;
	}

	public String getCmt() {
		return cmt;
	}

	public void setCmt(String cmt) {
		this.cmt = cmt;
	}

	public Double getCredite() {
		return credite;
	}

	public void setCredite(Double credite) {
		this.credite = credite;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long[] getDatas() {
		return datas;
	}

	public void setDatas(Long[] datas) {
		this.datas = datas;
	}
}
